package com.yihaodian.search.query;

import java.util.HashMap;
import java.util.Map;

import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;

import com.yihaodian.api.search.SearchRequest;

public class SolrQueryRequestParser {

	public static SolrQueryRequest parse(SolrCore solrCore,
			SearchRequest searchRequest) {
		SolrParams solrParams = parse(searchRequest);
		return new LocalSolrQueryRequest(solrCore, solrParams);

	}

	public static SolrParams parse(SearchRequest searchRequest) {
		Map<String, String[]> map = new HashMap<String, String[]>();
		// MultiMapSolrParams.addParam(CommonParams.Q,
		// searchRequest.getQueryString(), map);
		MultiMapSolrParams.addParam(CommonParams.SORT,
				searchRequest.getSortString(), map);
		/**
		 * TODO SearchRequest params add to map
		 */
		return new MultiMapSolrParams(map);
	}

}
